/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package opk.Solver;

import java.awt.Point;

/**
 *
 * @author Dawid
 */
public class SortedPoint extends Point
{
    private double alfaValue;
    
    public SortedPoint(Point point, Point basePoint)
    {
        x = point.x ;
        y = point.y;

        if (basePoint == null) 
        {
            alfaValue = Integer.MIN_VALUE;
            return;
        }
        int alfaX = point.x - basePoint.x;
        int alfaY = point.y - basePoint.y;
        
        if (alfaX >= 0 && alfaY >= 0)
        {
            alfaValue = (double)alfaY/(Math.abs(alfaX) + Math.abs(alfaY));
        }
        else if (alfaX < 0 && alfaY >= 0)
        {
            alfaValue = 2 - (double)alfaY/(Math.abs(alfaX) + Math.abs(alfaY));
        }
        else if (alfaX < 0 && alfaY < 0)
        {
            alfaValue = 2 + (double)Math.abs(alfaY)/(Math.abs(alfaX) + Math.abs(alfaY));
        }
        else if (alfaX >= 0 && alfaY < 0)
        {
            alfaValue = 4 - (double)Math.abs(alfaY)/(Math.abs(alfaX) + Math.abs(alfaY));
        }
    }


    /**
     * @return the alfaValue
     */
    public double getAlfaValue()
    {
        return alfaValue;
    }

}
